var t = require("../../../@babel/runtime/helpers/objectSpread2"), a = require("../../../@babel/runtime/helpers/defineProperty");

require("../../../@babel/runtime/helpers/Arrayincludes");

var s = require("../../../utils/themeSkin/skinBehavior"), o = getApp(), e = [], d = "";

Page({
    behaviors: [ s ],
    data: {
        radioChoose: "",
        showChoose: !1,
        dispatch_types: [],
        has_many_goods: [],
        goodsDescription: "",
        show: !1,
        share: 0,
        language: "",
        list: [],
        carts: [],
        details: {},
        Height: "1100rpx",
        sn: "",
        nums: 0,
        index_goods: 0,
        activity_gid: "",
        current_page: 1,
        last_page: 1,
        goodsPopupShow: !1,
        specsShow: !1,
        hand_goods_obj: {},
        carList: [],
        hand_goods_id: "",
        message_card: "",
        showKefu: !1,
        customer_open: "",
        cservice: "",
        service_mobile: "",
        service_QRcode: "",
        popThumb: "",
        popTitle: "",
        popNum: 0,
        popPrice: "",
        show2: !1,
        goodsInfo: {},
        specid: "",
        has_many_options: [],
        current_index: 0,
        code_id: "",
        id: "",
        sn_code: ""
    },
    onLoad: function(t) {
        var a = wx.getStorageSync("langIndex");
        this.setData({
            language: a.en,
            code_id: t.code_id || "",
            sn_code: t.sn_code || ""
        }), t.share && this.setData({
            share: t.share
        });
        var s = wx.getStorageSync("yz_basic_info");
        if (s && wx.setNavigationBarTitle({
            title: s.home.mailInfo.name
        }), t.scene) {
            var e = decodeURIComponent(t.scene);
            if (console.log(e, "==="), e) {
                var i = [];
                i = e.split("&"), console.log(i, "info_arr=>>");
                for (var d = 0; d < i.length; d++) {
                    var n;
                    "i" == (n = i[d].split("="))[0] && this.setData({
                        code_id: n[1]
                    }), "m" == n[0] && o._setMid(n[1]), "s" == n[0] && this.setData({
                        sn_code: n[1]
                    });
                }
            }
        } else if (t.code_id || t.sn_code) wx.setStorageSync("exchange_code", {
            code_id: t.code_id,
            sn_code: t.sn_code
        }); else {
            var c = wx.getStorageSync("exchange_code"), r = c.code_id, h = c.sn_code;
            this.setData({
                code_id: r,
                sn_code: h
            });
        }
        this.getData();
    },
    video_handle: function() {
        o.tips("兑换数量最多为1");
    },
    share_handle: function() {
        this.onShareAppMessage();
    },
    Hidden_overlay: function() {
        this.setData({
            show: !1
        });
    },
    change: function(t) {
        this.setData({
            sn: t.detail.value
        });
    },
    binding_handle: function() {
        var t = this;
        o._getNetWork({
            url: o.getNetAddresss("plugin.exchange-code.api.record.bind"),
            data: {
                sn: this.data.sn
            },
            success: function(a) {
                var s = a.data, e = s.result, i = s.msg, d = s.data;
                o.tips(i), e && (t.setData({
                    sn: "",
                    code_id: d.code_id,
                    sn_code: d.sn
                }), t.getData());
            }
        });
    },
    getData: function() {
        var t = this;
        o._getNetWork({
            url: o.getNetAddresss("plugin.exchange-code.api.list.info"),
            data: {
                id: this.data.code_id,
                sn: this.data.sn_code,
                scope: "pass"
            },
            success: function(a) {
                var s = a.data, e = s.result, i = s.msg, d = s.data;
                if (0 == e) return o.tips(i);
                t.setData({
                    details: d,
                    customer_open: d.cservice.customer_open,
                    cservice: d.cservice.cservice,
                    service_mobile: d.cservice.service_mobile,
                    service_QRcode: d.cservice.service_QRcode
                }), 2 == d.type && t.setData({
                    sn: d.current_code || t.data.sn_code
                }), 0 != d.login_status ? (1 == t.data.share && t.setData({
                    show: !0
                }), 1 == d.type && (t.getGoods({
                    id: d.id
                }), t.setData({
                    sn_code: d.current_code
                }))) : t.setData({
                    show: !0
                });
            }
        });
    },
    getGoods: function() {
        var t = this, a = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
        o._getNetWork({
            url: o.getNetAddresss("plugin.exchange-code.api.list.goodList"),
            data: a,
            success: function(a) {
                var s = a.data, e = s.result, i = s.msg, d = s.data;
                if (0 == e) return o.tips(i);
                if (t.setData({
                    current_page: d.current_page,
                    last_page: d.last_page
                }), 1 == d.current_page) t.data.list = d.data.forEach(function(t) {
                    t.count = 0;
                }), t.setData({
                    list: d.data || []
                }), d.data && d.data.length <= 5 && t.setData({
                    Height: "auto"
                }); else {
                    d.data.forEach(function(t) {
                        t.count = 0;
                    });
                    var n = d.data, c = t.data.list.concat(n);
                    t.setData({
                        list: c
                    });
                }
            }
        });
    },
    getMoreData: function() {
        this.data.current_page >= this.data.last_page || this.getGoods({
            page: this.data.current_page + 1,
            id: this.data.code_id
        });
    },
    login: function() {
        wx.navigateTo({
            url: "/pages/login/login"
        });
    },
    to_list: function() {
        wx.navigateTo({
            url: "/packageI/redeem_code/center/center"
        });
    },
    severShowTap: function() {
        this.setData({
            showKefu: !0
        });
    },
    check: function() {
        var t = this, a = [], s = [];
        this.data.list.forEach(function(t) {
            if (t.count >= 1) {
                1 !== t.has_option && a.push({
                    goods_id: t.id,
                    total: t.count,
                    option_id: "0"
                }), s.includes(t.plugin_id) || s.push(t.plugin_id);
            }
        }), this.data.has_many_goods && 0 !== this.data.has_many_goods.length && this.data.has_many_goods.forEach(function(t) {
            t.total >= 1 && a.push({
                goods_id: t.goods_id,
                total: t.total,
                option_id: t.option_id
            });
        });
        var e;
        e = a.map(function(t) {
            return t.goods_id;
        }), console.log(JSON.stringify(a), "arr=>>"), o._getNetWork({
            url: o.getNetAddresss("plugin.exchange-code.api.record.exchangeCheck"),
            data: {
                sn: this.data.sn_code,
                goods: JSON.stringify(a)
            },
            success: function(i) {
                var d = i.data, n = d.result, c = d.msg, r = d.data;
                n ? t.getLog(e, a, s) : r && 0 !== r.length ? 1 == r.need_choose ? t.setData({
                    showChoose: !0,
                    dispatch_types: r.dispatch_types
                }) : t.submitGoods() : o.tips(c);
            }
        });
    },
    closeChoose: function() {
        this.setData({
            showChoose: !1
        });
    },
    toBuy: function() {
        this.submitGoods();
    },
    typeChange: function(t) {
        this.setData({
            radioChoose: Number(t.detail)
        });
    },
    submitGoods: function() {
        var t = this, a = [], s = [];
        if (!this.data.showChoose || this.data.radioChoose.toString()) {
            if (this.data.showChoose) for (var e = 0; e < this.data.dispatch_types[this.data.radioChoose].member_carts.length; e++) a.push(this.data.dispatch_types[this.data.radioChoose].member_carts[e].goods_id), 
            s.push({
                total: this.data.dispatch_types[this.data.radioChoose].member_carts[e].total,
                goods_id: this.data.dispatch_types[this.data.radioChoose].member_carts[e].goods_id,
                option_id: this.data.dispatch_types[this.data.radioChoose].member_carts[e].option_id
            });
            a = a.join(","), s = JSON.stringify(s), o._getNetWork({
                url: o.getNetAddresss("plugin.exchange-code.api.log.create"),
                data: {
                    id: this.data.sn_code
                },
                success: function(e) {
                    var i = e.data, d = i.result, n = i.msg, c = i.data;
                    if (0 == d) return o.tips(n);
                    var r = "tag=exchange_code&goodsId=".concat(a, "&goods=").concat(s, "&current_code=").concat(t.data.details.code, "&name=").concat(t.data.details.name, "&exchange_code_id=").concat(c.exchange_code_id);
                    wx.navigateTo({
                        url: "/packageD/buy/myOrder_v2/myOrder_v2?".concat(r)
                    });
                }
            });
        } else wx.showToast({
            icon: "none",
            title: "请先选择配送方式",
            duration: 1500
        });
    },
    selectSpecs: function(t, a, s) {
        var o = {}, e = 0;
        "first" == a ? (o = t, e = t.id) : (o = t.target.dataset.item || t.currentTarget.dataset.item, 
        e = t.target.dataset.id || t.currentTarget.dataset.id), this.manageSpecs(o), this.setGoodsSpecs(o), 
        this.setGoodsSpecsChangeInfo(e);
    },
    manageSpecs: function(t) {
        var a = {};
        if (a.id = t.id, a.specid = t.specid, a.title = t.title, e.length > 0) {
            for (var s = 0; s < e.length; s++) e[s].specid == a.specid && e.splice(s, 1);
            e.push(a);
        } else e.push(a);
        if (e.length == this.data.goodsInfo.has_many_specs.length) {
            for (var o = [], i = 0; i < this.data.goodsInfo.has_many_specs.length; i++) for (var d = 0; d < e.length; d++) if (this.data.goodsInfo.has_many_specs[i].id == e[d].specid) {
                o.push(e[d]);
                break;
            }
            e = o;
        }
        this.setGoodsDescription();
    },
    setGoodsDescription: function() {
        var t = "";
        if (e.length == this.data.goodsInfo.has_many_specs.length) {
            t = "已选择 ";
            for (var a = 0; a < e.length; a++) t += e[a].title + " ";
            this.setData({
                goodsDescription: t
            });
        } else {
            t = "请选择 ";
            for (var s = 0; s < this.data.goodsInfo.has_many_specs.length; s++) for (var o = 0; o < e.length; o++) if (this.data.goodsInfo.has_many_specs[s].id != e[o].specid) {
                t += this.data.goodsInfo.has_many_specs[s].title + " ";
                break;
            }
            this.setData({
                goodsDescription: t
            });
        }
    },
    setGoodsSpecs: function(t) {
        for (var a = 0; a < this.data.goodsInfo.has_many_specs.length; a++) t.specid != this.data.goodsInfo.has_many_specs[a].id && this.setGoodsSpecsStatus(this.data.goodsInfo.has_many_specs[a].specitem, t.id);
    },
    setGoodsSpecsStatus: function(t, a) {
        for (var s = [], o = 0; o < this.data.goodsInfo.has_many_options.length; o++) for (var e = this.data.goodsInfo.has_many_options[o].specs.split("_"), i = 0; i < e.length; i++) e[i] == a && s.push(this.data.goodsInfo.has_many_options[o]);
        for (var d = 0; d < s.length; d++) for (var n = s[d].specs.split("_"), c = 0; c < n.length; c++) if (n[c] != a && 0 == s[d].stock) for (var r = 0; r < t.length; r++) n[c] == t[r].id && (t[r].c = !0); else if (n[c] != a && s[d].stock > 0) for (var h = 0; h < t.length; h++) n[c] == t[h].id && (t[h].c = !1);
    },
    setGoodsSpecsChangeInfo: function(t) {
        var a = "";
        if (e.sort(function(t, a) {
            return t.id - a.id;
        }), e.length === this.data.goodsInfo.has_many_specs.length) {
            for (var s = "", i = 0; i < e.length; i++) s += e[i].id + "_";
            s = s.substring(0, s.length - 1), this.setData({
                specid: s
            });
            for (var n = 0; n < this.data.goodsInfo.has_many_options.length; n++) if (s === this.setGoodsSpecsBySort(this.data.goodsInfo.has_many_options[n].specs)) {
                a = this.data.goodsInfo.point_goods ? this.data.goodsInfo.point_goods.point_option[n].goods_point : this.data.goodsInfo.has_many_options[n].product_price, 
                console.log(a, "popPrice-434"), this.setData({
                    popPrice: a
                });
                var c = o._isTextEmpty(this.data.goodsInfo.has_many_options[n].thumb) ? this.data.goodsInfo.thumb : this.data.goodsInfo.has_many_options[n].thumb;
                this.setData({
                    popThumb: c
                }), d = this.data.goodsInfo.has_many_options[n].id;
                break;
            }
        } else {
            for (var r = "", h = 0; h < e.length; h++) r += e[h].id + "_";
            this.setData({
                specid: r
            });
        }
        var g = this.data.has_many_goods.filter(function(t) {
            return t.option_id == d;
        });
        console.log(d, "optionsId===="), console.log(g, "_goods===-501"), 0 == g.length ? this.setData({
            popNum: 0
        }) : this.setData({
            popNum: g[0].total
        });
    },
    setGoodsSpecsBySort: function(t) {
        var a = t.split("_");
        a.sort(function(t, a) {
            return t - a;
        });
        for (var s = "", o = 0; o < a.length; o++) s += a[o] + "_";
        return s = s.substring(0, s.length - 1);
    },
    getLog: function(t, a, s) {
        var e = this;
        o._getNetWork({
            url: o.getNetAddresss("plugin.exchange-code.api.log.create"),
            data: {
                id: this.data.sn_code
            },
            success: function(i) {
                var n = i.data, c = n.result, r = n.msg, h = n.data;
                if (0 == c) return o.tips(r);
                if (s.includes(46)) {
                    var g = e.data.list.filter(function(t) {
                        if (t.count >= 1) return t;
                    });
                    wx.navigateTo({
                        url: "/packageC/Myshaky/enrollEnter/enrollEnter?id=".concat(g[0].relation_id, "&exchange_code_id=").concat(h.exchange_code_id)
                    });
                }
                if (s.includes(113)) {
                    var _ = e.goods_total();
                    wx.navigateTo({
                        url: "/packageD/buy/myOrder_v2/myOrder_v2?current_code=".concat(e.data.details.code, "&name=").concat(e.data.details.name, "&tag=store_projects_goods&exchange_code_id=").concat(h.exchange_code_id, "&goodsId=").concat(t[0], "&total=").concat(_)
                    });
                }
                if (s.includes(140)) {
                    var l = e.goods_total();
                    wx.navigateTo({
                        url: "/packageD/buy/myOrder_v2/myOrder_v2?optionsId=".concat(d, "&total=").concat(l, "&current_code=").concat(e.data.details.code, "&name=").concat(e.data.details.name, "&tag=-2&exchange_code_id=").concat(h.exchange_code_id, "&goodsId=").concat(t[0])
                    });
                }
                if (s.includes(101)) {
                    var u = e.goods_total();
                    wx.navigateTo({
                        url: "/packageD/buy/myOrder_v2/myOrder_v2?total=".concat(u, "&current_code=").concat(e.data.details.code, "&name=").concat(e.data.details.name, "&tag=appointment_goods&exchange_code_id=").concat(h.exchange_code_id, "&goodsId=").concat(t[0])
                    });
                }
                if (s.includes(144)) {
                    var p = a[0].option_id || "0";
                    wx.navigateTo({
                        url: "/packageF/consumption/orderAffirm/orderAffirm?goodsId=".concat(t[0], "&e_id=").concat(h.exchange_code_id, "&total=").concat(a[0].total, "&optionsId=").concat(p)
                    });
                }
                (s.includes(0) || s.includes(120) || s.includes(44) || s.includes(103)) && wx.navigateTo({
                    url: "/packageD/buy/myOrder_v2/myOrder_v2?current_code=".concat(e.data.details.code, "&name=").concat(e.data.details.name, "&tag=exchange_code&exchange_code_id=").concat(h.exchange_code_id, "&goodsId=").concat(t, "&goods=").concat(JSON.stringify(a))
                });
            }
        });
    },
    goods_total: function() {
        var t = 0;
        return this.data.list.forEach(function(a) {
            a.count >= 1 && (t += a.count);
        }), t;
    },
    redeem: function() {
        var t = this;
        2 == this.data.details.type ? o._getNetWork({
            url: o.getNetAddresss("plugin.exchange-code.api.record.levelExchange"),
            data: {
                id: this.data.sn
            },
            success: function(a) {
                var s = a.data, e = s.result, i = s.msg;
                e ? t.setData({
                    show: !0,
                    message_card: i,
                    sn: ""
                }) : o.tips(i);
            }
        }) : this.check();
    },
    openGoodsDetail: function(t) {
        var a = t.currentTarget.dataset.item;
        a.id == this.data.hand_goods_id ? this.setData({
            goodsPopupShow: !0
        }) : (this.data.hand_goods_id = a.id, this.getGoodsDetails(a.id, "goodsDetails")), 
        this.setData({
            index_goods: t.currentTarget.dataset.i,
            activity_gid: a.id
        });
    },
    goodsDetailCartAdd: function(t) {
        var a = this;
        console.log(t, "===>>>>>>"), this.data.list.forEach(function(t) {
            if (t.id == a.data.activity_gid) if (1 == t.has_option) {
                a.selectOption(t.id, i, t), a.setData({
                    goodsPopupShow: !1,
                    specsShow: !1
                });
            } else a.setData({
                goodsPopupShow: !1,
                specsShow: !0
            });
        });
    },
    getGoodsDetails: function(t, s) {
        var e = this, i = o.getNetAddresss("goods.goods.get-goods-page");
        o._postNetWork({
            url: i,
            data: {
                id: Number(t)
            },
            success: function(t) {
                var o, i = t.data;
                if (1 !== i.result) return e.tips(i.msg);
                var d = "";
                "goodsDetails" == s ? d = "goodsPopupShow" : "specs" == s && (d = "specsShow"), 
                e.setData((a(o = {}, d, !0), a(o, "hand_goods_obj", i.data.get_goods), o));
            }
        });
    },
    submitAction: function() {
        var t = this;
        if (e.length < this.data.goodsInfo.has_many_specs.length) return this.setData({
            show2: !1
        }), void wx.showToast({
            title: this.data.goodsDescription,
            icon: "none"
        });
        var a = this.data.popNum + 1;
        if (this.data.has_many_goods.push({
            option_id: d,
            goods_id: this.data.list[this.data.current_index].id,
            total: 1
        }), 1 == this.data.details.single_order) {
            if (this.data.has_many_goods && 0 !== this.data.has_many_goods.length) {
                var s = this.data.has_many_goods.filter(function(a) {
                    if (a.goods_id == t.data.list[t.data.current_index].id) return a;
                });
                this.data.has_many_goods = s;
            }
            this.data.list.forEach(function(a) {
                a.id !== t.data.list[t.data.current_index].id && (a.count = 0);
            });
        } else this.data.list.forEach(function(a) {
            a.id === t.data.list[t.data.current_index].id && (a.count = 1);
        });
        console.log(this.data.has_many_goods, "this.data.has_many_goods"), this.setData({
            has_many_goods: this.data.has_many_goods,
            list: this.data.list,
            popNum: a
        }), this.updateNums();
    },
    updateNums: function() {
        var t = this, a = 0;
        this.data.has_many_goods && 0 !== this.data.has_many_goods.length && (this.data.has_many_goods.forEach(function(s) {
            s.goods_id == t.data.list[t.data.current_index].id && (a += s.total);
        }), this.data.list[this.data.current_index].count = a);
        var s = 0;
        this.data.list.forEach(function(t) {
            s += t.count;
        }), this.setData({
            nums: s,
            list: this.data.list
        }), this.data.nums > this.data.details.exchange_limit && o.tips("选择的数量已经超过兑换数量限制，请取消后再重新选择！");
    },
    close: function() {
        this.setData({
            show2: !1
        });
    },
    close_yz_specs_popup: function(t) {
        var a = this;
        if (1 == t.detail.clicktype) {
            this.data.carts.forEach(function(s) {
                s.id == a.data.activity_gid ? (s.total = t.detail.goodsCount, s.option_id = t.detail.optionsId) : (s.total = 0, 
                s.option_id = "0");
            }), this.data.list.forEach(function(s, o) {
                s.id == a.data.activity_gid ? s.option_id = t.detail.optionsId : 0 == s.has_option && (s.option_id = "0"), 
                1 == a.data.details.single_order ? s.id == a.data.activity_gid ? a.data.list[o].count = t.detail.goodsCount : a.data.list[o].count = 0 : s.id == a.data.activity_gid && (a.data.list[o].count = t.detail.goodsCount);
            });
            var s = 0;
            this.data.list.forEach(function(t) {
                s += t.count;
            }), this.setData({
                specsShow: !1,
                nums: s,
                list: this.data.list,
                carts: this.data.carts
            });
        } else this.setData({
            specsShow: !1
        });
    },
    selectOption: function(t) {
        var a = this;
        console.log(t), d = "", e = [];
        var s = t.currentTarget.dataset.item, i = t.currentTarget.dataset.index;
        this.setData({
            specid: "",
            current_index: i,
            activity_gid: s.id,
            popTitle: s.title,
            popPrice: s.price,
            popThumb: s.thumb,
            show2: !0,
            popNum: 0
        });
        var n = o.getNetAddresss("goods.goods.get-goods-page");
        o._postNetWork({
            url: n,
            data: {
                id: Number(s.id)
            },
            success: function(t) {
                var s, o = t.data;
                if (1 !== o.result) return a.tips(o.msg);
                if (a.setData({
                    goodsInfo: o.data.get_goods,
                    has_many_options: a.data.has_many_options.concat(o.data.get_goods.has_many_options)
                }), !a.data.specid.length) {
                    var e = a.data.goodsInfo.min_price + "-" + a.data.goodsInfo.max_price;
                    a.data.goodsInfo.point_goods && (e = a.data.goodsInfo.point_goods.min_point + "-" + a.data.goodsInfo.point_goods.max_point), 
                    a.setData({
                        popPrice: e
                    });
                }
                a.setData({
                    goodsDescription: "请选择"
                });
                for (var i = 0; i < a.data.goodsInfo.has_many_specs.length; i++) s = a.data.goodsDescription, 
                s += "" + a.data.goodsInfo.has_many_specs[i].title;
                if (a.setData({
                    goodsDescription: s
                }), !a.data.optionsId) for (var d = 0; d < a.data.goodsInfo.has_many_specs.length; d++) if (a.data.goodsInfo.goods_option_ids && a.data.goodsInfo.goods_option_ids.length >= 0) for (var n = 0; n < a.data.goodsInfo.has_many_specs[d].specitem.length; n++) a.data.goodsInfo.has_many_specs[d].specitem[n].id == Number(a.data.goodsInfo.goods_option_ids[d]) && a.selectSpecs(a.data.goodsInfo.has_many_specs[d].specitem[n], "first", d); else a.selectSpecs(a.data.goodsInfo.has_many_specs[d].specitem[0], "first", d);
            }
        });
    },
    showGoodPup: function(a, s, o, e) {
        var i = this;
        this.data.carts && 0 !== this.data.carts.length ? (this.data.carts.forEach(function(s) {
            s.id !== a && i.data.carts.push(t(t({}, o), {}, {
                total: i.data.list[e].count,
                goods_id: o.id
            }));
        }), this.setData({
            carts: this.data.carts
        })) : (this.data.carts.push(t(t({}, o), {}, {
            total: this.data.list[e].count,
            goods_id: o.id
        })), this.setData({
            carts: this.data.carts
        })), this.setData({
            activity_gid: a,
            index_goods: e
        }), a == this.data.hand_goods_id ? this.setData({
            specsShow: !0
        }) : (this.data.hand_goods_id = a, this.getGoodsDetails(a, "specs"));
    },
    changeAddCount: function(t) {
        var a = t.currentTarget.dataset.i, s = 0;
        1 == a ? (s = this.data.popNum + 1, this.data.has_many_goods.forEach(function(t) {
            t.option_id == d && (t.total = s);
        })) : 0 == this.data.popNum ? this.data.has_many_goods.forEach(function(t) {
            t.option_id == d && (t.total = 0);
        }) : (s = this.data.popNum - 1, this.data.has_many_goods.forEach(function(t) {
            t.option_id == d && (t.total = s);
        })), this.setData({
            popNum: s,
            list: this.data.list,
            has_many_goods: this.data.has_many_goods
        }), this.updateNums();
    },
    reduceCartNum: function(t) {
        var a = this, s = t.currentTarget.dataset.cartid;
        this.data.list.forEach(function(t, o) {
            t.id == s && (1 == t.count ? a.data.list[o].count = 0 : a.data.list[o].count -= 1);
        }), this.setData({
            list: this.data.list,
            nums: this.data.nums - 1
        }), this.data.nums > this.data.details.exchange_limit && o.tips("选择的数量已经超过兑换数量限制，请取消后再重新选择！");
    },
    addCartNum: function(t) {
        var a = this, s = t.currentTarget.dataset.cartid;
        this.data.list.forEach(function(t, o) {
            t.id == s && (a.data.list[o].count += 1);
        }), this.setData({
            list: this.data.list,
            nums: this.data.nums + 1
        }), this.data.nums > this.data.details.exchange_limit && o.tips("选择的数量已经超过兑换数量限制，请取消后再重新选择！");
    },
    cart: function(t) {
        var a = this, s = t.currentTarget.dataset.item, e = 0;
        d = "", this.data.list.forEach(function(t, o) {
            1 == a.data.details.single_order ? s.id == t.id ? a.data.list[o].count = 1 : a.data.list[o].count = 0 : s.id == t.id && (a.data.list[o].count = 1);
        }), this.data.list.forEach(function(t) {
            e += t.count;
        }), 1 == this.data.details.single_order && this.setData({
            specid: "",
            has_many_goods: []
        }), this.setData({
            list: this.data.list,
            nums: e
        }), this.data.nums > this.data.details.exchange_limit && o.tips("选择的数量已经超过兑换数量限制，请取消后再重新选择！");
    },
    onReady: function() {},
    onShow: function() {
        this.setData({
            showChoose: !1
        });
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        if (1 != this.data.share) return {
            title: this.data.details.share_title,
            imageUrl: this.data.details.share_icon,
            path: "/packageI/redeem_code/index/index?id=" + this.data.id + "&code_id=" + this.data.code_id
        };
        var t = wx.getStorageSync("wxShareInfo"), a = t.title, s = t.imgUrl, o = t.description;
        return a || s || o ? {
            title: a,
            imageUrl: s,
            path: "/packageI/redeem_code/index/index?id=" + this.data.id + "&code_id=" + this.data.code_id
        } : void 0;
    }
});